﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnitForVSTS.NUnitTest;
using Microsoft.VisualStudio.TestTools.Common;
using System.Collections;
using NUnitForVSTS;
using NUnitSide = NUnit.Core;
// We are using multiple namespaces with muliple classes with the same name, different meaning
// Therefore some alliasses to improve clarity
using TestTarget = NUnitTest.UnitTest.Targets;
using TestTargetVb = NUnitTest.UnitTest.TargetsVb;
namespace NUnitForVSTS.NUnitTest.UT
{
    /// <summary>
    /// Summary description for SourceFileExplorerTest
    /// </summary>
    [TestClass]
    [Serializable]
    public class SourceFileExplorerTest
    {
        /// <summary>
        /// Explorers the load location.
        /// </summary>
        [TestMethod]
        public void ExplorerLoadLocation()
        {
            SourceFileExplorer explorer = new SourceFileExplorer();
            ICollection col = explorer.Read(typeof(TestTarget.TestFailed).Assembly.Location, null, new Warnings());
            Assert.AreEqual(31, col.Count);
        }

        /// <summary>
        /// Explorers the load location.
        /// </summary>
        [TestMethod]
        [Ignore]
        public void ExplorerLoadLocationVb()
        {
            SourceFileExplorer explorer = new SourceFileExplorer();
            ICollection col = explorer.Read(typeof(TestTargetVb.NUnitTest).Assembly.Location, null, new Warnings());
            Assert.AreEqual(1, col.Count);
        }

        /// <summary>
        /// Warning Handler
        /// </summary>
        [Serializable]
        private class Warnings : IWarningHandler
        {
            #region IWarningHandler Members

            /// <summary>
            /// Writes the specified sender.
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="ea">The <see cref="Microsoft.VisualStudio.TestTools.Common.WarningEventArgs"/> instance containing the event data.</param>
            public void Write(object sender, WarningEventArgs ea)
            {
                Console.WriteLine(ea.Warning);
            }

            #endregion
        }
    }
}
